<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">取消延时执行</button>
</body>
<script>
    var btn=document.getElementById("btn");
    //可以延迟执行一段代码
    var timeId=setTimeout(function(){
        alert("3秒时间到！");
    },3000)
    //cleaiTimeout(id);
    //清除特定id的延迟执行
    btn.onclick=function(){
        clearTimeout(timeId);
    }
</script>
</html>